<!DOCTYPE HTML />
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>用户注册</title>
    <link href="/css/main.css" rel="stylesheet"/>
    <?php include_once("common/common_js.php") ?>
</head>
<body>
<?php include_once("common/banner.php"); ?>
<div class="warpper">
    <?php include_once("common/header.php"); ?>
    <div class="al">
        <h3>基本信息</h3>

        <div class="content">
            <form name="form1" action="/index.php/Passport/register" method="post">
                <table>
                    <tr>
                        <td width="80">用户名</td>
                        <td><input type="text" name="userName" id="userName" class="f_txt"/> 注：昵称注册后不能修改，并且是全站唯一</td>
                        <td rowspan="4" style="text-align:center;">
                        </td>
                    </tr>
                    <tr>
                        <td>密码</td>
                        <td cols="2"><input name="password" id="password" type="password" class="f_txt"/></td>
                    </tr>
                    <tr>
                        <td>确认密码</td>
                        <td cols="2"><input name="repassword" id="repassword" type="password" class="f_txt"/></td>
                    </tr>
                    <tr>
                        <td>邮箱</td>
                        <td cols="2"><input name="email" id="email" type="text" class="f_txt"/>&nbsp;注：用于找回密码</td>
                    </tr>

                    <tr>
                        <td>安全问题</td>
                        <td cols="2">
                            <select name="questionDesciption" style="width:250px;" id="questionDesciption">
                                <option>请选择问题</option>
                                <option>您父亲的姓名是？</option>
                                <option>您母亲的姓名是？</option>
                                <option>您父亲的生日？</option>
                                <option>您母亲的生日？</option>
                                <option>您最爱的宠物叫什么名字？</option>
                                <option value="myself">自定义问题</option>
                            </select>&nbsp;注：用于找回密码
                        </td>
                    </tr>
                    <tr id="customQuestion" style="display: none">
                        <td>请输入您的问题</td>
                        <td cols="2"><input name="question" id="question" type="text" class="f_txt"/></td>
                    </tr>
                    <tr>
                        <td>答案</td>
                        <td cols="2"><input name="answer" id="answer" type="text" class="f_txt"/></td>
                    </tr>
                    <!--  <tr>
                        <td>昵称</td>
                        <td cols="2"><input type="text" class="f_txt"/></td>
                    </tr>-->
                    <!--    <tr>
                        <td>姓别</td>
                        <td cols="2"><input type="radio">男 <input type="radio">女</td>
                    </tr>
                    <tr>
                        <td>生日</td>
                        <td cols="2"><input type="text" class="f_txt"/></td>
                    </tr>
                    <tr>
                        <td>爱好</td>
                        <td cols="2"><textarea type="text" rows="3" cols="10" style="width:250px"></textarea></td>
                    </tr>
                    <tr>
                        <td>个性签名</td>
                        <td cols="2"><textarea type="text" rows="3" cols="10" style="width:250px"></textarea></td>
                    </tr>
                    -->
                    <tr>
                        <td></td>
                        <td><input type="button" onclick="subm()" value="保存" class="f_btn"/><input type="button"
                                                                                                   value="返回"
                                                                                                   class="f_btn"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script language="javascript">
    $(function() {
        $("#questionDesciption").bind("change", function() {
            if ($(this).val() == "myself") {
                $("#customQuestion").show();
            } else {
                $("#question").val($(this).val());
            }
        })
    })
    function subm() {
        if ($("#userName").val() == "") {
            alert("请输入用户名");
            return false;
        }
        if ($("#password").val() == "") {
            alert("请输入密码");
            return false;
        }
        if ($("#password").val() != $("#repassword").val()) {
            alert("密码与确认密码不一致");
            return false;
        }
        if ($("#email").val() == "") {
            alert("请输入邮箱地址");
            return false;
        }
        var re = new RegExp(/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/g);
        var re1 = new RegExp(/^[-_A-Za-z0-9\.]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/);
        if (!re.test($("#email").val()) && !re1.test($("#email").val())) {
            alert("请正确输入您的 email 地址！");
            $("#email").focus();
            return false;
        }
        if ($("#question").val() == "") {
            alert("请务必设置您的安全问题");
            return false;
        }
        $.get("/index.php/ajax/checkUserNameRegister", {userName:$("#userName").val()}, function(data) {
            if (data == 1) {
                document.form1.submit();
            }
            else {
                alert("对不起，您的用户名已经注册过，请更换");
            }
        })
    }
</script>
</body>
</html>